/**
 *   Copyright (C) 2012  Development Solutions (DS) Software
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *   The following additional terms will apply to the software provided with
 *   this file.
 *      1. Preserve the original authors’ name.
 *      2. Documenting all contributions and specify the contributor's name,
 *         the date of the contribution and some email to future contact.
 * 
 */
package org.dss.gil.service;

import org.apache.log4j.Logger;


/**
 *  
 *  @author  Fernando Gil <lobho.gil@gmail.com>
 *  @since   September 2012
 *  @version 1.0
 */
public class ValidationService {
    
    private static Logger logger = Logger.getLogger(ValidationService.class.getName());
    
    /*********************************************************************
     ********************* S I N G L E T O N *****************************
     *********************************************************************/
    private static ValidationService INSTANCE = null;

    public static ValidationService getInstance() {
        if (INSTANCE == null)
            INSTANCE = new ValidationService();
        return INSTANCE;
    }

    private ValidationService(){}
    
    /*********************************************************************
     ************************** S E R V I C E S **************************
     *********************************************************************/
    
    public boolean isInteger(String number) {
        try{
            Integer.parseInt(number);
            return true;
        }catch(Exception ex){
            return false;
        }
    }
    
    public boolean isDouble(String number) {
        try{
            Double.parseDouble(number);
            return true;
        }catch(Exception ex){
            return false;
        }
    }
    
    public boolean isHH_MM_SS(String time) {
        String[] values = time.split(":");
        if(values.length==3){
            return(isInteger(values[0])&&isInteger(values[1])&&isInteger(values[2]));
        }
        return false;
    }
    
}
